﻿using System;
using System.Collections.Generic;
using scheduler.Model;

namespace scheduler
{
    public class PopupReminder : IReminder
    {
        public TodoInfo TodoInfo { get; set; }

        public ReminderInfo Info { get; set; }

        private static Dictionary<TodoInfo, NotificationForm> formMap = 
            new Dictionary<TodoInfo, NotificationForm>();

        public void Execute()
        {
            NotificationForm form;
            if(formMap.TryGetValue(TodoInfo, out form))
            {
                form.BringToFront();
                return;
            }

            App.Logger.Log("Poping up.. [Todo:" + TodoInfo.Title + "]");

            form = new NotificationForm();
            form.TodoInfo = TodoInfo;
            form.Show();
            formMap[TodoInfo] = form;
            form.FormClosed += (sender, args) => {
                Console.WriteLine("?");
                formMap.Remove(TodoInfo);
            };
        }
    }
}